package com.lyc.yuki.module.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lyc.yuki.common.result.ResponseResult;
import com.lyc.yuki.module.system.domain.vo.UserVO;
import com.lyc.yuki.module.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: lyc
 * @Date: 2025/7/8 21:36
 */
@RestController
@RequestMapping("/system/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/page")
    public ResponseResult<IPage<UserVO>> getUserPage(@RequestParam(defaultValue = "1") Integer current,
                                                     @RequestParam(defaultValue = "10") Integer size) {
        IPage<UserVO> page = userService.selectUserPage(current, size);
        return ResponseResult.successWithData(page);
    }

    @GetMapping("/{username}")
    public ResponseResult<List<UserVO>> getUserListByUserName(@PathVariable String username) {
        List<UserVO> userVOList =  userService.getUserListByUserName(username);
        return ResponseResult.successWithData(userVOList);
    }
}
